<?php

namespace Fize\SBSPHP\PHP80\L01NamedArguments;

/**
 * 命名参数
 */
class NamedArguments
{

    protected string $name;

    protected ?string $value;

    protected ?int $age;

    public function __construct($name)
    {
        $this->name = $name;
        $this->value = null;
        $this->age = null;
    }

    public function getName(): string
    {
        return $this->name;
    }

    public function getValue(): ?string
    {
        return $this->value;
    }

    public function getAge():?int
    {
        return $this->age;
    }

    public function set($value, $name = null, $age = null): void
    {
        $this->value = $value;
        if (!is_null($name)) {
            $this->name = $name;
        }
        if (!is_null($age)) {
            $this->age = $age;
        }
    }
}